import { requestClient } from '#/api/request';

export namespace ProjectStageApi {
  export interface Stage {
    id?: number;
    name: string;
    memo?: string;
    status?: string;
    projectId?: number;
    [key: string]: any;
  }

  export interface SaveParams extends Stage {}
  export interface UpdateParams extends Stage {}

  export interface ListParams {
    page?: number;
    pageSize?: number;
    searchKey?: string;
    status?: string;
    projectId?: number;
  }

  export interface ListResult {
    data: Stage[];
    total: number;
  }
}

/**
 * 获取阶段列表（分页+查询）
 */
export function getProjectStageListApi(params: ProjectStageApi.ListParams) {
  return requestClient.post<ProjectStageApi.ListResult>('/project/stage/list', params);
}

/**
 * 获取阶段详情
 */
export function getProjectStageDetailApi(id: number | string) {
  return requestClient.get(`/project/stage/get?id=${id}`);
}

/**
 * 新增阶段
 */
export function saveProjectStageApi(data: ProjectStageApi.SaveParams) {
  return requestClient.post('/project/stage/save', data);
}

/**
 * 删除阶段
 */
export function deleteProjectStageApi(id: number | string) {
  return requestClient.delete(`/project/stage/delete?id=${id}`);
}
